
import React,{Component} from 'react';
import { BrowserRouter, Route, Redirect,Switch } from 'react-router-dom'

import AuthRoute from './component/authroute'
import Login from './container/login'
import Register from './container/register'
import BossInfo from './container/bossinfo'
import GeniusInfo from './container/geniusinfo'
import Dashboard from './container/dashboard'
import Chat from './container/chat'

class App extends Component {
  constructor(props){
    super(props)
    this.state={
      hasError:false
    }
  }
  componentDidCatch(err,info){
    console.log(err,info)
    this.setState({
      hasError:true
    })
  }
  render() {
    return this.state.hasError
    ?<h2>页面出错</h2>
    :(
      <BrowserRouter>
      <div>
        <AuthRoute></AuthRoute>
        <Switch>
          <Route path='/bossinfo' component={BossInfo}></Route>
          <Route path='/geniusinfo' component={GeniusInfo}></Route>
          <Route path="/login" component={Login}></Route>
          <Route path="/register" component={Register}></Route>
          <Route path="/chat/:user" component={Chat}></Route>
          <Route component={Dashboard}></Route>
        </Switch>
      </div>
    </BrowserRouter>
    );
  }
}

export default App;
